using System;
using System.Collections.Generic;
using System.Text;
using Castle.Windsor;
using log4net.Config;
using Castle.MicroKernel;
using Castle.MicroKernel.SubSystems.Configuration;  
using Castle.Model.Configuration;
using Castle.Facilities.IBatisNetIntegration;

namespace testcastle
{
    using testcastle.DAL;
    using testcastle.Domain; 
    class App
    {
        public const String DATA_MAPPER = "AccessSqlMap";
        IWindsorContainer container;
        static void Main(string[] args)
        {
            App app = new App();
            
            app.DoBusiness();
        }
        public void DoBusiness()
        {
            container = CreateContrainer();
            container.AddComponent("accountDao", typeof(AccountDao));
            AccountDao dao = container["accountDao"] as AccountDao;
            Account ac = dao.GetAccount(4);

 

        }
        public IWindsorContainer  CreateContrainer()
        {
            IWindsorContainer container = new WindsorContainer(new DefaultConfigurationStore());

            MutableConfiguration confignode = new MutableConfiguration("facility");

            IConfiguration sqlMap = confignode.Children.Add(new MutableConfiguration("sqlMap"));
            sqlMap.Attributes["id"] = DATA_MAPPER;
            sqlMap.Attributes["config"] = "sqlMap.config";

            container.Kernel.ConfigurationStore.AddFacilityConfiguration("IBatisNet", confignode);
            container.AddFacility("IBatisNet", new IBatisNetFacility());
 
            return container;
        }

    }
}
